<%@page import="pl.org.waff.repository.*"%>
<%@page import="pl.org.waff.WaffServlet"%>
<%@page import="java.util.Set, java.util.Iterator, java.util.List" %>
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<jsp:useBean id="repository" class="pl.org.waff.repository.InMemoryContentCache" scope="application" />
<jsp:useBean id="cmswitch" class="pl.org.waff.cm.CMSwitch" scope="session" />
<div>
    <% String docId=cmswitch.getDocid();
    Document document=repository.getDocument(docId);
    %>
    <table width="100%">
        <tr>
            <td width="75%"><b><%=document.getTitle()%></b></td>
            <td><jsp:include page="newcomment.jsp"/></td>
        </tr>
    </table>
    <table width="100%">
        <tr><td>Title</td><td>Author</td><td>Modified</td><td>Status</td></tr>
        <%
            List list = repository.findComments(docId, null);
            String cId;
            Comment comment;
            for (int i = 0; i < list.size(); i++) {
                cId = (String) list.get(i);
                comment = repository.getComment(cId);
                if (comment != null) {
                    out.print("<tr>");
                    out.print("<td><a href='cmswitch.do?view=c&commentid=" + comment.getId() + "'>" + comment.getTitle() + "</a></td>");
                    out.print("<td>" + comment.getAuthor() + "</td>");
                    out.print("<td>" + comment.getModifiedAsString("yyyy-MM-dd HH:mm") + "</td>");
                    out.print("<td>" + comment.getStatus() + "</td>");
                    out.print("</tr>");
                }
            }
        %>
    </table>
</div>
